FROM {{ namespace }}/{{ image_prefix }}designate-base:{{ tag }}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"

{% block designate_backend_bind9_header %}{% endblock %}

{% import "macros.j2" as macros with context %}

{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %}
   {% set designate_backend_bind9_packages = ['bind'] %}

{{ macros.install_packages(designate_backend_bind9_packages | customizable("packages")) }}

{% elif base_distro in ['debian', 'ubuntu'] %}
   {% set designate_backend_bind9_packages = ['bind9'] %}

{{ macros.install_packages(designate_backend_bind9_packages | customizable("packages")) }}

{% endif %}

{% set designate_backend_bind_name = 'bind' if base_distro in ['debian', 'ubuntu'] else 'named' %}

RUN mkdir -p /var/lib/kolla/ /var/lib/{{ designate_backend_bind_name }}/ /run/{{ designate_backend_bind_name }} \
     && chown -R root: /var/lib/{{ designate_backend_bind_name }} /run/{{ designate_backend_bind_name }} \
     && chmod 755 /run/{{ designate_backend_bind_name }} \

{% block designate_backend_bind9_footer %}{% endblock %}
{% block footer %}{% endblock %}
